package com.csaba.connector.axa;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.csaba.connector.ServiceException;
import com.csaba.connector.axa.model.AXASession;
import com.csaba.connector.model.Account;
import com.csaba.connector.model.Session;
import com.csaba.connector.service.AbstractBankService;
import com.csaba.connector.service.DummyService;

public class AXADummyService extends AbstractBankService implements DummyService, Codes
{
	private final static String POSITIVE_RESULT = "\"SessionExtended\"";

	@Override
	public void execute( final Session session ) throws ServiceException
	{
		final AXASession axa = (AXASession) session;
		final String account = ( (Account) session.getRemoteProperty(RP_SELECTED_ACCOUNT) ).getNumber();

		final NameValuePair[] dummyRequest = new NameValuePair[] {// 
		new BasicNameValuePair("AccountNumber", account),//
		};

		final String dummyResult = axa.doPost(AXASession.getRequestURL(REQUEST_DUMMY), dummyRequest);

		axa.debugFile("dummyResult", dummyResult);

		if ( !dummyResult.equals(POSITIVE_RESULT) )
		{
			throw AXAUtil.serverError(dummyResult);
		}
	}
}
